{extend name='layui/base'/}

{block name="style"}
<style>

</style>
{/block}
{block name="main"}

<div class="site-demo-upload">
    <img id="LAY_demo_upload" src="http://res.layui.com/images/fly/fly.jpg">
    <div class="site-demo-upbar">
        <div class="layui-box layui-upload-button">
            <form target="layui-upload-iframe" method="get" key="set-mine" enctype="multipart/form-data"
                  action="/test/upload.json"><input type="file" name="file" class="layui-upload-file" id="test"></form>
            <span class="layui-upload-icon"><i class="layui-icon"></i>上传图片</span></div>
    </div>
</div>

<form action="#">

    <div>
        <input type="file" name="photo" lay-title="上传图片" class="layui-upload-file">
    </div>
    <button class="layui-btn">
        提交
    </button>
</form>


{/block}
{block name="js_extension"}
<script>
    function onLayuiReady() {
        layui.upload({
            url: "{:url('layui/upload')}",
            before: function (input) {
                console.log(input);
            },
            success: function (res, input) {
                console.log(res); //上传成功返回值，必须为json格式
                input.setAttribute("value",res.data['file']);
            }
        });
    }
</script>
{/block}